<?php

use App\Helpers\CSRF;
use App\Helpers\HTML;
use App\Helpers\URL;

if ($event !== 'signupAction') { ?>
<?php $app->render('templates/centered_open', ['app' => $app, 'title' => 'Registro']) ?>
  <main class="card is-full-width max-w-lg">
    <header>
      <h1>Registro</h1>
    </header>
<?php } ?>
    <div id="signupAction">
      <?php if (isset($error)) { ?>
        <?php $app->render('components/error', ['error' => $error]) ?>
      <?php } ?>
      <form action="<?= URL::event('signup/action', null, 'signupAction') ?>" method="post" target=htmz>
        <input type="hidden" name="<?= CSRF::getVarname() ?>" value="<?= $app->local(CSRF::getVarname()) ?>">
        <p>
          <label for="username">Usuario</label>
          <input type="text" name="username" id="username" placeholder="juanperez123" value="<?= HTML::esc($values['username']) ?>" class="<?= $status['username'] ?>">
          <small class="text-error"><?= HTML::esc($validations['username']) ?></small>
        </p>
        <p>
          <label for="email">Correo</label>
          <input type="email" name="email" id="email" placeholder="juan.perez@email.com" value="<?= HTML::esc($values['email']) ?>" class="<?= $status['email'] ?>">
          <small class="text-error"><?= HTML::esc($validations['email']) ?></small>
        </p>
        <p>
          <label for="password">Contraseña</label>
          <input type="password" name="password" id="password" placeholder="Ingresa tu contraseña" class="<?= $status['password'] ?>">
          <small class="text-error"><?= HTML::esc($validations['password']) ?></small>
        </p>
        <p>
          <label for="confirm_password">Confirmar contraseña</label>
          <input type="password" name="confirm_password" id="confirm_password" placeholder="Ingresa de nuevo tu contraseña" class="<?= $status['confirm_password'] ?>">
          <small class="text-error"><?= HTML::esc($validations['confirm_password']) ?></small>
        </p>
        <p>
          <input type="submit" value="Enviar" class="is-full-width">
        </p>
        <p class="text-center">
          <a href="<?= URL::site('login') ?>">¿Ya tienes una cuenta? Inicia sesión.</a>
        </p>
      </form>
    </div>
<?php if ($event !== 'signupAction') { ?>
  </main>
<?php $app->render('templates/centered_close', ['app' => $app]) ?>
<?php } ?>
